home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15427 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.th-darmstadt.de!news
  2. From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Is it OK to delete const *type pointers?
  5. Date: Thu, 04 Apr 1996 17:19:13 +0200
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Message-ID: <3163E871.237C228A@intellektik.informatik.th-darmstadt.de>
  8. References: <4jhjub$fpc@mag1.magmacom.com>
  9. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; SunOS 4.1.3 sun4m)
  14.  
  15. Acme Instant Dehydrated Boulder Kit wrote:
  16. > Some compilers let me do this, others do not. What I would like to know is,
  17. > what does Stroustrup think? I.e. is it written somewhere in the ARM (I checked
  18. > but can't find it) or in the draft standard? If somoene could e-mail me a
  19. > quote or a pointer to a place where I can read where it says such a thing
  20. > should or should not be allowed, I would appreciate it!
  21. > const int* array= new int[30];
  22. > delete[] array;
  23. > MSVC says "can not delete const*"
  24. > Some versions of G++ also don't let me do this.
  25. > Is deleting an object technically considered changing that object's value?
  26.  
  27. The standard doesn't specify this (5.3.5.4):
  28. ... It is unspecified whether the deletion of an object changes its
  29.     value. ...
  30.  
  31. According to the DWP a dtor can be invoked even for a const-object
  32. (12.4 class.dtor). Thus I would say the above code should compile.
  33.  
  34.     Enno
  35.